<? 
//$project_id = $_POST['project_id'];
//if ($project_id == NULL)  {
//	$project_id = $_GET['project_id'];
//}
// temporary fix on page_title
//$project_title = "Project Title";
if ($project_id <> NULL)  {
	$query = "select * from markers where project = ".$project_id;
$result = mysql_query($query);
//$markers = mysql_fetch_array($result);
$rr = mysql_num_rows($result);
if ( !$result )
{
	echo ( "<P>Error getting marker data: markers.php" . mysql_error() . "</P>" );
}
else
	{
//write out markers
$i = 1;
//echo '<script type="text/javascript">var myobj = {"markers":{"marker":[';
echo '<script type="text/javascript">var myobj = {
	"title": {"pagetitle":"'.$project_title.'"},
	"background": {"fname":"'.$project_background.'"},
	"bg_width": {"width":"'.$project_width.'"},
	"bg_height": {"height":"'.$project_height.'"},
	"markerIcon": {"fname":"'.$project_markerIcon.'"},
	"iwidth": {"width":"'.$project_iwidth.'"},
	"iheight": {"height":"'.$project_iheight.'"},
    "markers":{
        "marker":[';
while($row = mysql_fetch_array($result))
  {
	echo '{';
	echo '"ident":'.$row['ident'].','; //must have an ident to be in database
	echo '"posx":'.$row['posx'].',';
	echo '"posy":'.$row['posy'].',';
	echo '"icon":'.$row['icon'].',';
	echo '"iwidth":'.$row['iwidth'].',';
	echo '"iheight":'.$row['iheight'].',';
	echo '"title":'.json_encode($row['title']).',';
	
	if ($row['txt'] <> NULL)  {
		$stxt = json_encode($row['txt']);
		//  this produces:   "<p>Some<\/p><p>text<\/p>\r\n"
		echo '"txt":'.$stxt.','; } 
		
	else {
		echo '"txt":"Enter Text" ,'; }	

	echo '"pic":'.$row['pic'].',';
	echo '"width":'.$row['width'].',';
	echo '"height":'.$row['height'].',';
	echo '"lnk":'.json_encode($row['lnk']).'}';			//no comma after final section
	if ($i < $rr) {
		echo ',';							//no comma after final marker
	}
	$i++;
	
  }
echo ']}}';
echo '</script>';
}//else

} // top if

?>
